<!DOCTYPE html>
<html lang="en">
<!--header-->
<include file="Public:header"/>
<!--header-->
<section id="main-content">
    <section class="wrapper">
        <h3><i class="fa fa-angle-right"></i> 添加/修改订单信息</h3>

        <!-- BASIC FORM ELELEMNTS -->
        <div class="row mt">
            <div class="col-lg-12">
                <div class="form-panel">
                    <h4 class="mb"><i class="fa fa-angle-right"></i> 订单信息
                        <a class="btn btn-theme btn-default" href="{:U('index')}">返回</a>
                    </h4>
                    <form id="orders" class="form-horizontal style-form" method="post" action="{:U('add')}"  enctype="multipart/form-data">
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">商品</label>
                            <div class="col-sm-10"><!--订单状态  1待付款 2待发货 3 待收货 4待评论 5已完成-->
                                <select id="goods_ids" name="goods_ids" class="form-control">
                                    <option value="0">请选择商品</option>
                                    <!--<option value="goods_name" <if condition="$list['goods_name'] neq ''">selected</if>>其它商品</option>-->
                                    <foreach name="goods" item="v">
                                        <option value="{$v.id}" <if condition="$list['goods_id'] == $v['id']">selected</if>>{$v.name}</option>
                                    </foreach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">数量</label>
                            <div class="col-sm-10">
                                <input <if condition="$list">readonly</if> name="nums"  value="{$list.nums}" type="text"  class="form-control" placeholder="请输入商品数量">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">订单总价</label>
                            <div class="col-sm-10">
                                <input <if condition="$list">readonly</if> id="moneys"  name="moneys" value="{$list.moneys}" type="text"  class="form-control" placeholder="请输入订单总价">
                            </div>
                        </div>
                        <if condition="$list && $list['trade_no']">
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">订单编号</label>
                                <div class="col-sm-10">
                                    <input id="trade_no" readonly value="{$list.trade_no}" type="text"  class="form-control" >
                                </div>
                            </div>

                        </if>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">客户姓名</label>
                            <div class="col-sm-10">
                                <input <if condition="$list">readonly</if> id="a_name" name="a_name" value="{$list.name}" type="text"  class="form-control" placeholder="请输入用户姓名">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">客户电话</label>
                            <div class="col-sm-10">
                                <input <if condition="$list">readonly</if> id="a_phone" name="a_phone" value="{$list.phone}" type="text"  class="form-control" placeholder="请输入电话">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">客户地址</label>
                            <div class="col-sm-10">
                                <input <if condition="$list">readonly</if> id="a_address" name="a_address" value="{$list.address}" type="text"  class="form-control" placeholder="请输入地址">
                            </div>
                        </div>
                        <if condition="$list['status'] eq 1">
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">订单状态</label>
                                <div class="col-sm-10">
                                    待付款
                                </div>
                            </div>
                        </if>
                        <if  condition="$list['status'] eq 2 || $list['status'] eq 6">
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">订单状态</label>
                                <div class="col-sm-10">
                                    <select id="status" name="status" class="form-control">
                                        <option value="2" <if condition="$list['status'] eq 2">selected</if> >未发货</option>
                                        <option value="3" <if condition="$list['status'] eq 3">selected</if> >已发货</option>
                                    </select>
                                </div>
                            </div>
                        </if>
                        <if condition="$list['status'] eq 3">
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">订单状态</label>
                                <div class="col-sm-10">
                                   待收货
                                </div>
                            </div>
                        </if>
                        <if  condition="$list['status'] eq 4">
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">订单状态</label>
                                <div class="col-sm-10">
                                    待评价
                                </div>
                            </div>
                        </if>
                        <if  condition="$list['status'] eq 5">
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">订单状态</label>
                                <div class="col-sm-10">
                                    订单已完成
                                </div>
                            </div>
                        </if>
                        <div id="contents" class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">订单备注</label>
                            <div class="col-sm-10">
                                <textarea  name="bei_zhu" class="input" type="text" style="width: 500px;height: 200px;">{$list.bei_zhu}</textarea>
                            </div>
                        </div>
                        <input type="hidden" id="id" name="id" value="{$list.id}">
                        <input type="hidden" name="trade_nos"  value="{$list.trade_no}">
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label"></label>
                            <div class="col-sm-10">
                                <if condition="$list">
                                    <input   type="button" id="tianjia" class="btn btn-theme" value="提交修改" style="width: 150px;margin-left: 60px">
                                </if>
                                <if condition="!$list">
                                    <!--<input   type="submit" id="tianjias" class="btn btn-theme" value="提交新订单" style="display: none;width: 150px;margin-left: 60px">
                                    <input   type="button" id="tianjiass"  class="btn" value="提交新订单" style="width: 150px;margin-left: 60px">-->
                                    <input   type="submit" id="tianjias" class="btn btn-theme" value="提交新订单" style="width: 150px;margin-left: 60px">
                                </if>
                                <input  type="reset" class="btn btn-warning" value="重置" style="width: 150px">
                            </div>
                        </div>
                    </form>
                </div>
            </div><!-- col-lg-12-->
        </div><!-- /row -->
    </section>
</section>
<!--footer-->
<include file="Public:footer"/>
<!--footer-->
<script type="text/javascript" src="__PUBLIC__/ui/lib/layer/2.4/layer.js"></script>
<script>
    //商品添加
    $("#goods_ids").change(function () {
        var goods_id = $("#goods_ids").val();
        if(goods_id == "goods_name"){
            $("#shang").show();
        }else{
            $("#shang").hide();
        }
    })
    //检测用户手机号信息
    _phones   = false;
    $("#user_phone").blur(function () {
        var phone = $("#user_phone").val();
        $.ajax({
            type:"post",
            url:"{:U('phone')}",
            data:{phone:phone},
            success:function (res) {
                if(res == 1){
                    layer.open({
                        title: '订单添加提示',
                        content: "未找到该用户",
                    });
                }else{
                    $("#tianjias").show();
                    $("#tianjiass").hide();
                    $('#nickname').html("用户微信昵称："+res);
                    _phones   = true;
                }
            }
        })
    })
    $("#tianjiass").click(function(){
        layer.open({
            title: '订单添加提示',
            content: "未找到该用户,不可添加",
        });
    });
    /* $("#tianjias").click(function(){
     layer.confirm('请确认订单信息无误？', {
     title: '添加新订单提示：',
     btn: ['确定'], //可以无限个按钮
     btns: ['定']
     }, function(index, layero){
     if(_phones){
     $("#admin").submit();
     }else{
     layer.open({
     title: '订单添加提示',
     content: "未找到该用户,不可添加",
     });
     }
     });
     });*/
    $("#tianjia").click(function(){
        /*var ji_id    = $('.aaaa').val();
         alert(ji_id)
         var id       = $("#id").val();
         var bei_zhu  = editor.html();
         var numbers  = $("#numbers").val();
         var status   = $('#status').val();
         var trade_no = $('#trade_no').val();
         var names    = $('#names').val();*/
        layer.confirm('确认修改该订单信息吗？', {
            title: '订单修改提示：',
            btn: ['确定'] //可以无限个按钮
        }, function(index, layero){
            $("#orders").submit();
            /*$.ajax({
             type:"post",
             data:{id:id,status:status,bei_zhu:bei_zhu,numbers:numbers,trade_no:trade_no,names:names},
             url:"{:U('xiu')}",
             success:function (res) {
             if(res == 1){
             layer.open({
             title: '',
             content: "修改成功",
             });
             if(currpage == 1){
             location.href="__APP__/Dashboard/Orders/index";
             }else{
             location.href="__APP__/Dashboard/Orders/index/currpage/"+currpage;
             }
             }
             if(res == 2){
             layer.open({
             title: ''
             ,content: "修改失败"
             });
             _pass = false;
             }
             }
             })*/
        });
    });
    //图片上传
    function openFile(){
        return  $("#avatar").click();
    }
    function PreviewImage(imgFile)
    {
        var filextension=imgFile.value.substring(imgFile.value.lastIndexOf("."),imgFile.value.length);
        var o=imgFile.files[0];
        filextension=filextension.toLowerCase();
        if ((filextension!='.jpg')&&(filextension!='.jpeg')&&(filextension!='.png')&&(filextension!='.bmp'))
        {

            imgFile.focus();
        }else if(o.size > 2097152){
            imgFile.focus();
        }
        else
        {
            var path;
            path=window.URL.createObjectURL(imgFile.files[0]);// FF 7.0以上
            $('.ph-user').attr({src:path});
        }
    }
</script>

</body>
</html>
